#include <iostream>
#include <string>
#include <cstring>
#include <unordered_map>
#include <fstream>
#include "Common.hpp"
//#include "Dictionary.hpp"

const std::string gpath = "./";
const std::string gdictname = "dict.txt";
const std::string gsep = ": ";
std::unordered_map<std::string, std::string> _dictionary;

bool LoadDictionary()
{
    std::string file = "/home/Greg_122/linux/lesson/d23_socket/3.DictServer/Test.cc";
    std::ifstream in(file.c_str());
    if (!in.is_open())
    {
        //LOG(LogLevel::ERROR) << "open file" << file << "error";
        perror("open file fail");
        return false;
    }

    // apple:苹果
    std::string line;
    std::getline(in, line);
    std::cout << line << std::endl;
    // while (std::getline(in, line))
    // {
    //     std::string key;
    //     std::string value;
    //     if (SplitString(line, &key, &value, gsep))
    //     { // line-> key value
    //         _dictionary.insert(std::make_pair(key, value));
    //     }
    //     std::cout << key << "   " << value << std::endl;
    // }

    in.close();
    return true;
}

int main()
{
    // std::string line = "apple: 苹果";
    // std::string key;
    // std::string value;
    // SplitString(line, &key, &value, ": ");
    // std::cout << key << "   " << value << std::endl;

    LoadDictionary();

    return 0;
}